<?php
/**
 * Created by PhpStorm.
 * User: lee
 * Date: 12/7/18
 * Time: 3:38 PM
 */

//swoole_async_dns_lookup("ws://www.mumuhuli.com", function($host, $ip){
//    echo "{$host} : {$ip}\n";
//});
$domainName = 'www.mumuhuli.com';
$cli = new \Swoole\Http\Client($domainName, 9520);
//$cli->setHeaders(array('User-Agent' => 'swoole-http-client',
//    'Host' =>  $domainName,
//    'Accept' => 'text/html,application/xhtml+xml,application/xml',
//    'Accept-Encoding' => 'gzip',
//));
//$cli->setCookies(array('test' => 'value'));
$cli->on('message', function ($_cli, $frame) {
    echo '123123';
    echo $frame;
});

$cli->upgrade('/', function ($cli) {
    echo $cli->body;
    $cli->push("{'event':'addChannel','channel':'ok_sub_spot_usd_btc_ticker'}");
    $cli->push('{"action":"ping","event":"ping"}', WEBSOCKET_OPCODE_PING);
});